﻿using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace DataConvertLib
{
	/// <summary>
	/// ULong类型数据转换类
	/// </summary>
	// Token: 0x02000014 RID: 20
	[Description("ULong类型数据转换类")]
	public class ULongLib
	{
		/// <summary>
		/// 字节数组中截取转成64位无符号整型
		/// </summary>
		/// <param name="value">字节数组</param>
		/// <param name="start">开始索引</param>
		/// <param name="dataFormat">数据格式</param>
		/// <returns>返回一个ULong类型</returns>
		// Token: 0x060000C2 RID: 194 RVA: 0x000052EC File Offset: 0x000034EC
		[Description("字节数组中截取转成64位无符号整型")]
		public static ulong GetULongFromByteArray(byte[] value, int start = 0, DataFormat dataFormat = DataFormat.ABCD)
		{
			byte[] value2 = ByteArrayLib.Get8BytesFromByteArray(value, start, dataFormat);
			return BitConverter.ToUInt64(value2, 0);
		}

		/// <summary>
		/// 将字节数组中截取转成64位无符号整型数组
		/// </summary>
		/// <param name="value">字节数组</param>
		/// <param name="dataFormat">数据格式</param>
		/// <returns>返回Long数组</returns>
		// Token: 0x060000C3 RID: 195 RVA: 0x00005310 File Offset: 0x00003510
		[Description("将字节数组中截取转成64位无符号整型数组")]
		public static ulong[] GetULongArrayFromByteArray(byte[] value, DataFormat dataFormat = DataFormat.ABCD)
		{
			bool flag = value == null;
			if (flag)
			{
				throw new ArgumentNullException("检查数组长度是否为空");
			}
			bool flag2 = value.Length % 8 != 0;
			if (flag2)
			{
				throw new ArgumentNullException("检查数组长度是否为8的倍数");
			}
			ulong[] array = new ulong[value.Length / 8];
			for (int i = 0; i < value.Length / 8; i++)
			{
				array[i] = ULongLib.GetULongFromByteArray(value, 8 * i, dataFormat);
			}
			return array;
		}

		/// <summary>
		/// 将字符串转转成64位无符号整型数组
		/// </summary>
		/// <param name="value">字节数组</param>
		/// <param name="spilt">分隔符</param>
		/// <returns>返回ULong数组</returns>
		// Token: 0x060000C4 RID: 196 RVA: 0x00005380 File Offset: 0x00003580
		[Description("将字符串转转成64位无符号整型数组")]
		public static ulong[] GetULongArrayFromString(string value, string spilt = " ")
		{
			value = value.Trim();
			List<ulong> list = new List<ulong>();
			ulong[] result;
			try
			{
				bool flag = value.Contains(spilt);
				if (flag)
				{
					string[] array = value.Split(new string[]
					{
						spilt
					}, StringSplitOptions.RemoveEmptyEntries);
					foreach (string text in array)
					{
						list.Add(Convert.ToUInt64(text.Trim()));
					}
				}
				else
				{
					list.Add(Convert.ToUInt64(value.Trim()));
				}
				result = list.ToArray();
			}
			catch (Exception ex)
			{
				throw new ArgumentNullException("数据转换失败：" + ex.Message);
			}
			return result;
		}
	}
}
